package com.edushare.common.vo;

import java.util.List;

import com.edushare.common.exceptions.EduShareRuntimeException;
import com.edushare.common.exceptions.ProcessingException;
import com.edushare.common.global.SystemGlobals;
import com.edushare.common.vo.auto._PollQuestions;

public class PollQuestions extends _PollQuestions implements Comparable<PollQuestions>{
	
	private static final long serialVersionUID = 3485670433679876280L;
	public static final int QUESTION_TYPE_RATING 				= 10;
	public static final int QUESTION_TYPE_SINGLE_CHOICE 		= 20;
	public static final int QUESTION_TYPE_MULTIPLE_CHOICE 		= 30;
	public static final int QUESTION_TYPE_DESCRIBE				= 40;
	public static final int QUESTION_TYPE_PREFERENCES			= 50;
	public static final int QUESTION_TYPE_SHORT_TEXT			= 60;
	public static final int QUESTION_TYPE_DROPDOWN				= 70;
	
	public static final int ANSWER_REQUIRED						= 10;
	public static final int ANSWER_OPTIONAL						= 20;
	

	/**
	 * Can the question's response be summarised, mathematically?
	 * @return true, if mathematical average can be calculated
	 */
	public final boolean isResponseSummarizable(){
		if(		this.getQuestionType() == QUESTION_TYPE_DROPDOWN || 
				this.getQuestionType() == QUESTION_TYPE_MULTIPLE_CHOICE || 
				this.getQuestionType() == QUESTION_TYPE_RATING || 
				this.getQuestionType() == QUESTION_TYPE_SINGLE_CHOICE){
			return true;
		}else{
			return false;
		}
	}
	

	public boolean isRequired(){
		return super.getRequired() == ANSWER_REQUIRED; 
	}
	
	public int compareTo(PollQuestions arg0) {
		return getQuestionSerialNo() - arg0.getQuestionSerialNo();
	}

}
